From 21f246f964d9d8350ed849d2442a2e841e743b77 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Wed, 15 Apr 2020 07:59:39 -0600 Subject: [PATCH] Fallthrough corrections (#538) * fix an actual bug found by Wimplicit-fallthrough= * add comments for gcc wrt Wimplicit-fallthrough= The real fix is the to add the attribute [[fallthrough]]; which was added in c++17. gcc accepts this, but until c++17 there wasn't a requirement to ignore unrecognized attributes, so we can imagine a pre c++17 compiler might choke on it. --- dmtlog.cc | 3 ++- g7towin.cc | 2 +- skytraq.cc | 4 ++-- util.cc | 1 + xcsv.cc | 1 + 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/dmtlog.cc b/dmtlog.cc index 7497eb3b1..5b27d10db 100644 --- a/dmtlog.cc +++ b/dmtlog.cc @@ -586,7 +586,8 @@ inflate_buff(const char* buff, const size_t size, char** out_buff) switch (res) { case Z_NEED_DICT: - res = Z_DATA_ERROR; /* and fall through */ + res = Z_DATA_ERROR; + /* fallthrough */ case Z_DATA_ERROR: case Z_MEM_ERROR: (void)inflateEnd(&strm); diff --git a/g7towin.cc b/g7towin.cc index a0fc62cb1..4efcc98db 100644 --- a/g7towin.cc +++ b/g7towin.cc @@ -188,7 +188,7 @@ parse_line(char* buff, int index, const char* delimiter, Waypoint* wpt) if (strcmp(cin, "1.0e25") == 0) { break; } - /* !!! NO BREAK !!! */ + /* fallthrough */ case WPT_cD_OFS + 1: case WPT_cB_OFS + 6: WAYPT_SET(wpt, temperature, atof(cin)); diff --git a/skytraq.cc b/skytraq.cc index fabd379ed..099825268 100644 --- a/skytraq.cc +++ b/skytraq.cc @@ -785,7 +785,7 @@ process_data_item(struct read_state* pst, const item_frame* pitem, int len) case 0xc: /* POI item (same structure as full) */ poi = 1; - /* fall through: */ + /* fallthrough */ case 0x2: /* Multi HZ item */ if (len < MULTI_HZ_ITEM_LEN) { @@ -822,7 +822,7 @@ process_data_item(struct read_state* pst, const item_frame* pitem, int len) case 0x6: /* POI item (same structure as full) */ poi = 1; - /* fall through: */ + /* fallthrough */ case 0x4: /* full item */ if (len < FULL_ITEM_LEN) { diff --git a/util.cc b/util.cc index a0c6922d4..df16bd08f 100644 --- a/util.cc +++ b/util.cc @@ -483,6 +483,7 @@ str_match(const char* str, const char* match) return 0; /* incomplete escape sequence */ } /* pass-through next character */ + /* fallthrough */ default: if (*m != *s) { diff --git a/xcsv.cc b/xcsv.cc index 4fffd7b9f..c404fee78 100644 --- a/xcsv.cc +++ b/xcsv.cc @@ -1522,6 +1522,7 @@ XcsvFormat::xcsv_waypt_pr(const Waypoint* wpt) garmin_fs_t* gmsd = garmin_fs_t::find(wpt); buff = QString::asprintf(fmp.printfc.constData(), CSTR(garmin_fs_t::get_facility(gmsd, ""))); } + break; case XT_EMAIL: { garmin_fs_t* gmsd = garmin_fs_t::find(wpt); buff = QString::asprintf(fmp.printfc.constData(), CSTR(garmin_fs_t::get_email(gmsd, ""))); -- 2.30.2